package com.star.sync.elasticsearch.common;


import org.apache.commons.lang.StringUtils;

import java.lang.reflect.InvocationTargetException;
import java.util.Map;

import static org.apache.commons.beanutils.BeanUtils.setProperty;

public class BeanUtils {



    /**
     * 转换之前驼峰转大小写
     *
     * @param bean
     * @param properties
     * @throws IllegalAccessException
     * @throws InvocationTargetException
     */
    public static void populates(Object bean, Map<String, ? extends Object> properties) throws IllegalAccessException, InvocationTargetException {

        // Do nothing unless both arguments have been specified
        if ((bean == null) || (properties == null)) {
            return;
        }
        // Loop through the property name/value pairs to be set
        for (Map.Entry<String, ? extends Object> entry : properties.entrySet()) {
            // Identify the property name and value(s) to be assigned
             String name = entry.getKey();
            if (name == null) {
                continue;
            }

            // Perform the assignment for this property

            setProperty(bean, name, entry.getValue());

        }

    }






}
